package com.example.designmode.easyFactory;

/**
 * 创建工厂对象用来实例化需要创建的计算类
 */
public class OperationFactory {
    //根据输入的计算符号创建对应的计算类
    public static OperationAbstract CreateObject(String operate){
        OperationAbstract operationAbstract = null;
        switch (operate){
            case "+":
                operationAbstract = new AddOperation();
                break;
            case "-":
                operationAbstract = new SubOperation();
                break;
            case "*":
                operationAbstract = new MulOperation();
                break;
            case "/":
                operationAbstract = new DivOperation();
                break;
        }
        return operationAbstract;
    }
}
